<template>
<div style="width:100%;height:100%">
    <div>
        <button @click="sd++">{{sd}}</button>
        <button @click="sd++">{{sd|two}}</button>
        <button @click="sd++">{{sd|quanju}}</button>
        <button @click=intertime()>定时</button>
        <button @click="update()">刷新</button>
    </div>
    <div class="text" contenteditable=true ></div>
    <button @click="posrgo">进度条启动</button>
    <div style="height:30px ;width:400px;background-color: #ddd;">
      <div id="cil"
      :style="{textAlign:'right',backgroundColor: '#4CAF50','width':this.per+'%'}"
      >
        {{per}}%
        </div>
    </div>
</div>

</template>
<script>
export default {
  data () {
    return {
      sd: 0,
      per: 0
    }
  },
  watch: {
    sd: {
      handler: function () { console.log(74) },
      immediate: true
    }
  },
  methods: {
    intertime () {
      let timer = setInterval(() => { console.log(5) }, 1000)
      this.$once('hook:beforeDestroy', () => { clearInterval(timer) })
    },
    update () {
      this.$router.go(0)
    },
    posrgo () {
      if (this.per >= 100) { this.per = 0 }
      var that = this
      let time = setInterval(function () {
        that.per++
        // document.getElementById('cil').style.width = that.per + '%'
        if (that.per >= 100) { clearInterval(time) }
      }, 50)
    }
  },

  filters: {
    two: function (e) {
      return (e + 5)
    }
  }
}
</script>

<style >

.text{
    width: 400px;
    min-height: 100px;
    max-height: 300px;
    margin-left: auto;
    margin-right: auto;
    padding: 3px;
    outline: 0;
    border: 1px solid #a0b3d6;
    font-size: 12px;
    word-wrap: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    overflow-y: visible;
}

</style>
